<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            list-style: none;
            margin: 0;
            padding: 0;
        }
        a {
            text-decoration: none;
            color: #000;
            cursor: pointer;
        }
        .box {
            /* background-color: pink; */
        }
        .nav {
            display: flex;
        }
        /* 子代选择器 */
        .nav>li>a {
            display: block;
            width: 80px;
            height: 41px;
            text-align: center;
            line-height: 41px;
        }
        .nav>li {
            margin-left: 10px;
            margin-right: 10px;
        }

        .hidden {
            display: none;
        }

        .show {
            display: block;
        }

    </style>
</head>
<body>
    <div class="box">
        <ul class="nav">
            <li>
                <a href="javascript:;">微博</a>
                <ul class="hidden">
                    <li>免费邮箱</li>
                    <li>VIP邮箱</li>
                    <li>企业邮箱</li>
                </ul>
            </li>
            <li>
                <a href="javascript:;">博客</a>
                <ul class="hidden">
                    <li>免费邮箱</li>
                    <li>VIP邮箱</li>
                    <li>企业邮箱</li>
                </ul>
            </li>
            <li>
                <a href="javascript:;">邮箱</a>
                <ul class="hidden">
                    <li>免费邮箱</li>
                    <li>VIP邮箱</li>
                    <li>企业邮箱</li>
                </ul>
            </li>
            <li>
                <a href="javascript:;">网页</a>
                <ul class="hidden">
                    <li>免费邮箱</li>
                    <li>VIP邮箱</li>
                    <li>企业邮箱</li>
                </ul>
            </li>
        </ul>
    </div>
<!-- js -->
    <script>
        //1.获取元素
        var ul_nav = document.querySelector('.nav');
        //2.给买个li 添加一个鼠标显示和鼠标离开事件
        for (var i = 0; i < ul_nav.children.length; i++) {
            var liTemp = ul_nav.children[i];
            liTemp.onmouseover = function() {
                this.children[0].style.color = '#FECC5B';
                this.children[1].className = 'show';
            }

            liTemp.onmouseout = function() {
                this.children[0].style.color = '#000';
               this.children[1].className = 'hidden';
            }
        }
    </script>
</body>
</html>